<template>
  <CloudCascader
    style="width: 360px"
    :options="options"
    :showSearch="{ filter }"
    placeholder="Please select"
    @change="onChange"
  >
  </CloudCascader>
</template>

<script>
  export default {
    title: '5.搜索',
    subTitle: '可以直接搜索选项并选择。',
    data () {
      return {
        options: [
          {
            value: 'zhejiang',
            label: 'Zhejiang',
            children: [
              {
                value: 'hangzhou',
                label: 'Hangzhou',
                children: [
                  {
                    value: 'xihu',
                    label: 'West Lake',
                  },
                  {
                    value: 'xiasha',
                    label: 'Xia Sha',
                    disabled: true,
                  },
                ],
              },
            ],
          },
          {
            value: 'jiangsu',
            label: 'Jiangsu',
            children: [
              {
                value: 'nanjing',
                label: 'Nanjing',
                children: [
                  {
                    value: 'zhonghuamen',
                    label: 'Zhong Hua men',
                  },
                ],
              },
            ],
          },
        ],
      }
    },
    methods: {
      onChange (value, selectedOptions) {
        console.log(value, selectedOptions);
      },
      filter (inputValue, path) {
        return path.some(option => option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
      },
    }
  }
</script>

<style lang="scss">
</style>